//
//  HELCourseCell.m
//  NursingAssociation
//
//  Created by wsj2015 on 2017/2/17.
//  Copyright © 2017年 wsj2015. All rights reserved.
//

#import "HELCourseCell.h"
#import "UIImageView+BTimageView.h"
@implementation HELCourseCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    self.shengQingBtn.layer.borderColor = kMainColor.CGColor;
    self.shengQingBtn.layer.borderWidth = 1;
    wsj_cornerRadius(self.shengQingBtn, 4);
//    
//    self.creditTagL.hidden = YES;
 
    
    
}

- (IBAction)action:(id)sender {
   
    [UIView animateWithDuration:.35 animations:^{
        [self layoutIfNeeded];
    }];
    
}
- (void)setCourseListModel:(HELCourseListModel *)courseListModel{
    
    
    UILabel *label = [self.contentView viewWithTag:10086];
    if (label) {
        [label removeFromSuperview];
    }
    _courseListModel = courseListModel;
    self.unKnownL.text = [NSString stringWithFormat:@"%@分",courseListModel.credit];
    self.shengQingBtn.hidden = YES;
    self.titleL.text = courseListModel.courseName;
    [self.avatarIcon nc_setImageWithUrl:courseListModel.courseImage];
//    self.typeL.text = [NSString stringWithFormat:@"¥%.2f",[courseListModel.coursePrice doubleValue]];
    
    if ([courseListModel.coursePrice doubleValue] <= 0) {
        self.typeL.text =  @"";
    }else{
       self.typeL.text =  [NSString stringWithFormat:@"¥%.2f",[courseListModel.coursePrice doubleValue] ];
    }
    
    self.typeCountL.text = courseListModel.creditName;
    self.learningCountL.text = [NSString stringWithFormat:@"%@人在学",courseListModel.studyNumber];
    self.ratingL.text = [NSString stringWithFormat:@"%@星",courseListModel.avgScore?courseListModel.avgScore:@(0)];
    self.ratingView.value = [courseListModel.avgScore floatValue]/2;
    self.ratingView.userInteractionEnabled = NO;
}
- (void)setTag_MycourseList:(BOOL)tag_MycourseList{
    if (tag_MycourseList == YES) {
         self.typeL.text = @"";
        
    
        
    }
   
}

- (void)setIsCompleted:(BOOL)isCompleted
{
    
    
    if (isCompleted) {
        if (kScreenHeight >= 667) {
            [self addLabel];
        }
        
        
    }


}


- (void)addLabel{
    
    
    UILabel *label = [UILabel new];
    label.tag = 10086;
    
    if ([self.courseListModel.isCredit integerValue] == 1) {
        label.text =  @"已申请";
        label.textColor = kTxtColor;
        label.layer.borderColor = kTxtColor.CGColor;
    }else{
        label.text =  @"未申请";
        label.textColor = kPinchColor;
        label.layer.borderColor = kPinchColor.CGColor;
    }
    
   
    label.frame = CGRectMake(CGRectGetMaxX(self.unKnownL.frame) + 20, CGRectGetMinY(self.unKnownL.frame), 44, 17);
    label.font = [UIFont systemFontOfSize:10];
    label.textAlignment = NSTextAlignmentCenter;
    label.layer.borderWidth = 1;
    
    wsj_cornerRadius(label, 6);
    
    [self.contentView addSubview:label];
    
}




@end
